package com.hlm.demo.entity;

import com.hlm.demo.validator.admininfovalidator.AdminAddValidator;
import com.hlm.demo.validator.admininfovalidator.AdminLogValidator;
import com.hlm.demo.validator.admininfovalidator.AdminUpdValidator;
import jdk.nashorn.internal.runtime.regexp.joni.Regex;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.sql.Date;
import java.util.List;

/**
 *  管理员信息表对应的实体类
 */
public class AdminInfo implements Serializable {

    private Integer adminId;
    @NotBlank(message = "用户名不能为空或全是空格!",groups = {AdminAddValidator.class, AdminUpdValidator.class})
    private String adminCode;
    @NotBlank(message = "密码不能为空或全是空格!",groups = {AdminAddValidator.class})
    private String password;
    @NotBlank(message = "确认密码不能为空或全是空格!",groups = {AdminAddValidator.class})
    private String repeat;
    @NotBlank(message = "真实名字不能为空或全是空格!",groups = {AdminAddValidator.class,AdminUpdValidator.class,AdminLogValidator.class})
    @Pattern(regexp = "[0-9a-zA-Z\\u4e00-\\u9fa5]{1,20}$",message = "真实名字的长度只能字母,数字和汉字组成.且最大长度为20",groups = {AdminAddValidator.class,AdminUpdValidator.class,AdminLogValidator.class})
    private String adminName;
    @NotBlank(message = "手机号码不能为空或全是空格!",groups = {AdminAddValidator.class,AdminUpdValidator.class, AdminLogValidator.class})
    @Pattern(regexp = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$",message = "手机号格式不正确",groups = {AdminAddValidator.class,AdminUpdValidator.class, AdminLogValidator.class})
    private String telephone;
    @NotBlank(message = "邮箱不能为空或全是空格",groups = {AdminAddValidator.class,AdminUpdValidator.class,AdminLogValidator.class})
    @Email(message = "邮箱格式填写的不正确",groups = {AdminAddValidator.class,AdminUpdValidator.class,AdminLogValidator.class})
    private String email;
    private Date enrolldate;


    private List<AdminRole> adminRoleList;


    public Integer getAdminId() {
        return adminId;
    }

    public void setAdminId(Integer adminId) {
        this.adminId = adminId;
    }

    public String getAdminCode() {
        return adminCode;
    }

    public void setAdminCode(String adminCode) {
        this.adminCode = adminCode;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getRepeat() {
        return repeat;
    }

    public void setRepeat(String repeat) {
        this.repeat = repeat;
    }

    public String getAdminName() {
        return adminName;
    }

    public void setAdminName(String adminName) {
        this.adminName = adminName;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getEnrolldate() {
        return enrolldate;
    }

    public void setEnrolldate(Date enrolldate) {
        this.enrolldate = enrolldate;
    }

    public List<AdminRole> getAdminRoleList() {
        return adminRoleList;
    }

    public void setAdminRoleList(List<AdminRole> adminRoleList) {
        this.adminRoleList = adminRoleList;
    }


    @Override
    public String toString() {
        return "AdminInfo{" +
                "adminId=" + adminId +
                ", adminCode='" + adminCode + '\'' +
                ", password='" + password + '\'' +
                ", repeat='" + repeat + '\'' +
                ", adminName='" + adminName + '\'' +
                ", telephone='" + telephone + '\'' +
                ", email='" + email + '\'' +
                ", enrolldate=" + enrolldate +
                ", adminRoleList=" + adminRoleList +
                '}';
    }
}


